import request from '@/utils/request'



export const getIngredient = (param: any) =>
    request({
        url: "/ingredient/page",
        method: "post",
        data: param  // POST 请求通常使用 data 而不是 params
        // 或者如果后端需要 query 参数：
        // params: param
    })


// 删除单个食材
export const deleteIngredient = (ids: number) =>
    request({
      url: "/ingredient/deletedById",
      method: "delete",
      params: { ids }  // Axios会自动拼接到URL
    });

export const addIngredient =(param: any) => 
    request({
        url:"/ingredient/add",
        method:"post",
        data:param
    })

export const getIngredientById = (id : string) => 
    request({
        url:"/ingredient/getById",
        method:"get",
        params:{id}

    })

export const updateIngredient = (params:any) => 
    request({
        url:`/ingredient/update`,
        method:"put",
        data:params
    })


    
    // 获取配料列表
    export const getIngredientList = (params: any) => {
      return request({
        url: '/ingredient/list',
        method: 'get',
        params
      })
    }